#include <stdio.h>
#include <assert.h>

int my_strlen(char* string){
    int count=0;
    char* ptr=string;
    while (*ptr!='\0'){
        count++;
        ptr++;
    }
    return count;
}
 void Reverse(char* str){
    char* ptr1=str;
    char* ptr2=str+ my_strlen(str)-1;
    char tmp;
    while (ptr1<ptr2){
        tmp=*ptr1;
        *ptr1=*ptr2;
        *ptr2=tmp;
        ptr1++;
        ptr2--;
    }

}

void Circle(char* string,int n){
    char ptr=*string;
    int i;
    for(i=0;i<n;i++){
        char* left= string;
        int j;
        char temp=*left;
        for(j=0;j< my_strlen(&ptr);j++){  //实现左移动
            *left=*(left+1);
            left++;
        }
        *left=temp;
    }
}

void Print(const int* arr,int sz){
    int i;
    for(i=0;i<sz;i++){
        printf("%d ",*(arr+i));
    }
}

void Bubble_sort(int* arr,int sz){
    assert(arr!=NULL);
    int i;
    for(i=0;i<sz-1;i++){
        int flag=1;
        int j;
        for(j=0;j<sz-1-i;j++){
            if(arr[j]>arr[j+1]){
                int temp=arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=temp;
                flag=0;
            }
        }
        if(flag==1){
            break;
        }
    }
}

void Exchange_num(int* arr,int sz){
    int* left=arr;
    int* right=arr+sz-1;
    while (left<=right){
        if((*(left)%2==0)&&(*(right)%2!=0)){  //左为偶数，右为奇数，交换位置
            int temp=*left;
            *left=*right;
            *right=temp;
            left++;
            right--;
        } else if(*left%2!=0){  //左边为奇数，
            left++;
        } else if(*right%2==0){  //右边为偶数，左移
            right--;
        }
    }
}

int main(){
    /*char arr1[]="ABCD";
    Circle(arr1,2);
    printf("%s\n",arr1);
    char arr2[]="ABCD";
    Circle(arr2,1);
    printf("%s\n",arr2);*/
//    int ret= my_strlen("hajkhd");
//    printf("%d ",ret);
//    int arr[]={1,2,3,6,5,7,9,10};
//    int n=sizeof (arr)/sizeof (arr[0]);
//    Print(arr,n);
    int arr[]={9,8,7,6,5,4,3,2,1};
    int n=sizeof (arr)/sizeof (arr[0]);
    Exchange_num(arr,n);
    int i;
    for(i=0;i<n;i++){
        printf("%d ",*(arr+i));
    }
    return 0;
}
